package main

import (
	"fmt"

	"github.com/DATA-DOG/go-sqlmock"
	"github.com/jinzhu/gorm"
	// "github.com/jinzhu/gorm"
)

type MockGormV1 struct {
	DB   *gorm.DB
	mock sqlmock.Sqlmock
}

// 针对 jinzhu/gorm 版本的Gorm的mock
func MockDBGorm_V1() {
	db, mock, err := sqlmock.New()
	if err != nil {
		fmt.Printf("an error '%s' was not expected when opening a stub database connection", err)
	}

	mockDb := &MockGormV1{}
	mockDb.mock = mock
	mockDb.DB, _ = gorm.Open("mysql", db) // jinzhu/orm

	defer db.Close()
}
